home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
fortran
/
libry51.zip
/
LIBRY4B.DOC
< prev
next >
Wrap
Text File
|
1989-11-10
|
20KB
|
480 lines
.pa
QUICK LIST OF MATHEMATICAL SUBROUTINES
BFNLQ.... brute force method for nonlinear simultaneous equations (see BRYDN)
BFNLQD... double precision version of BFNLQ (see BRYDN)
BRYDN.... modified Broyden's method for nonlinear simultaneous equations
BRYDND... double precision version of BRYDN
CONJG.... conjugate gradient method for nonlinear simult. equns. (see BRYDN)
CONJGD... double precision version of CONJG (see BRYDN)
CUBIC.... solve a cubic equation
CUBICD... double precision form of CUBIC
FMIN..... find the minimum of a function within an interval
FMIND.... double precision version of FMIN
FZERO.... find the zero (root) of a function within an interval
FZEROD... double precision version of FZERO
GAUSP.... Gauss-Jordan elimination of simultaneous equations
GAUSPD... double precision form of GAUSP
JLDAY.... convert month/day/year to Julian (annual) day
LLSLC.... linear least-squares with linear constraints
LNREG.... linear regression
MADD..... matrix addition
MADDD.... double precision matrix addition
MCPY..... matrix copy
MCPYD.... double precision matrix copy
MDAY..... convert Julian (annual) day to month/day/year
MINV..... matrix inversion
MINVD.... double precision form of MINV
MPRD..... matrix product (multiplication)
MPRDD.... double precision matrix product (multiplication)
MSUB..... matrix subtraction
MSUBD.... double precision matrix subtraction
MTRA..... matrix transpose
MTRAD.... double precision matrix transpose
MTRS..... in-place transpose of a square matrix
MTRSD.... in-place transpose of a double precision square matrix
NTNLQ.... Newton's method for nonlinear simultaneous equations (see BRYDN)
NTNLQD... double precision version of NTNLQ (see BRYDN)
PROOT.... polynomial root finder
QUAD..... solve a quadratic
QUADD.... double precision form of QUAD
RAND..... random number generator (real)
RK4...... 4th order Runge-Kutta (solution of ordinary differential eqns.)
RK6D..... 6th order Runge-Kutta (solution of ordinary differential eqns.)
SPLNE.... determine coefficients for a cubic spline
SVD...... singular value decomposition using Householder transformations
TDIAG.... tridiagonal matrix solver
TDIAGD... double precision form of TDIAG
TREND.... compute trend of periodic function
NOTE: A word of caution about matrix operation subroutines. All of these
routines (MADD, MSUB, MCPY, MPRD, MSUB, MTRA, MTRS and their double
precision counterparts) use vector emulations. Subsequently, no
arrays can cross a segment boundary. See Chapter 7 for more
cautions.
.pa
MATHEMATICAL SUBROUTINES
NAME: BRYDN
PURPOSE: modified Broyden's method for nonlinear simultaneous equations
TYPE: subroutine (far external)
SYNTAX: CALL BRYDN(USER,XMIN,XMAX,X,F,N,M,WORK,MW,MCALL,IPRT,IER)
IMPUT: USER (far external) a subroutine that YOU MUST PROVIDE and
must be called by the sequence CALL USER(X,F)
XMIN,XMAX (REAL*4) arrays, upper and lower limits on X
N (INTEGER*2) number of elements in X
M (INTEGER*2) number of residuals
W (REAL*4) working space of dimension MW
MW (INTEGER*2) dimension of working space MW=5N+3M+N*N+N*M
MCALL (INTEGER*2) maximum function calls (set to zero for unlimited)
IPRT (INTEGER*2) print select (for IPRT=0 nothing is printed,
for IPRT=1 only a one line summary at the end is printed, for
IPRT=2 X, F, and G are printed at each iteration, and for IPRT=3
the Jacobian is also printed at each iteration)
need to open file 6 on the PC)
OUTPUT: X (REAL*4) solution vector
F (REAL*4) final residual
IER (INTEGER*2) error indicator
IER=0 indicates normal return
IER=1 indicates N<2
IER=2 indicates M<N
IER=3 indicates XMIN>XMAX conflict
IER=4 indicates insufficient work space (increase MW)
note that the printer output is going to go directly to the
printer unless you first spool it with by CALLing
SPOOL('FILE.EXT',IER); and no, the redirect ">" will not work
NOTE: This is a FAR more difficult problem than most people even
imagine! You can compare it to finding the lowest spot on
the face of the Earth given the rules of the game "Battle
Ship" where all you can do is call out coordinates and your
opponent answers with the elevation. You may find a rut or a
ditch somewhere; but it's highly unlikely that you will find
death valley, let alone some trench in the Pacific. Now extend
this analogy to many-dimensional space... get the point? So
don't get too upset if BRYDN can't find the solution you want.
I've tried all sorts of algorithms and this seems to work the
best for general problems.
If you have 6 equations and 6 unknowns then M=N=6. If you
have 12 equations and 6 unknowns then M=12 and N=6.
If all of your equations are linear, by all means don't use BRYDN,
you want LLSLC. If you have only one unknown then use FMIN.
For double precision use BRYDND.
Also available are the brute force method (BFNLQ & BFNLQD), the
conjugate gradient method (CONJG & CONJGD), and Newton's method
(NTNLQ & NTNLQD). The calling sequence, input, and output are
all the same as for BRYDN & BRYDND. The only differences is the
method and the required working space, MW (for BFNLQ, MW=3*N+M;
for CONJG, MW=8*N+M; and for NTNLQ, MW=6*N+2*M+N*N+N*M).
This is a little tricky, so I have included an example at the end of
this section.
NAME: CUBIC
PURPOSE: solve a cubic equation
TYPE: subroutine (far external)
SYNTAX: CALL SUBROUTINE CUBIC(A1,A2,A3,A4,R1,C1,R2,C2,R3,C3)
INPUT: A1,A2,A3,A4 (REAL*4) coefficients in cubic equation
OUTPUT: (R1,C1),(R2,C2),(R3,C3) (REAL*4) roots
NOTE: the equation has the form A1*X**3+A2*X**2+A3*X+A4=0
for double precision use CUBICD and don't forget to declare
A1,A2,A3,A4,R1,C1,R2,C2,R3,C3 all to be REAL*8 and if you
use constants, don't forget the 1.D0 or whatever.
NOTE: for double precision use CUBICD
NAME: FMIN
PURPOSE: find the minimum of a function within an interval
TYPE: REAL*4 function (far external)
SYNTAX: XMIN=FMIN(F,A,B)
INPUT: A,B (REAL*4) the search interval
F (a far external REAL*4 function) that you must supply
that may be called by FX=F(X)
OUTPUT: location of minimum
NOTE: for double precision use FMIND
NAME: FZERO
PURPOSE: find the zero (root) of a function within an interval
TYPE: REAL*4 function (far external)
SYNTAX: X0=FZERO(F,A,B)
INPUT: A,B (REAL*4) interval to look for root in
F (REAL*4 function) that YOU MUST SUPPLY and must be
called by the sequence FX=F(X)
OUTPUT: location of the root
NOTE: for double precision use FZEROD
NAME: GAUSP
PURPOSE: Gauss-Jordan elimination of simultaneous equations
TYPE: subroutine (far external)
SYNTAX: CALL GAUSP(A,B,X,JPIVOT,N,D,C,IER)
INPUT: A,B (REAL*4) arrays containing the equations to be solved
having dimensions (N,N) and (N) respectively
JPIVOT (INTEGER*2) working space of dimension "N"
N (INTEGER*2) the number of equations
OUTPUT: X (REAL*4) solution vector of dimension N
D (REAL*4) ALOG10(ABS(DETERMINANT)) log of the determinant
C (REAL*4) ALOG10(AMAX1(ABS(PIVOT))/AMIN1(ABS(PIVOT))) a
measure of the gradedness or condition of the matrix
IER (INTEGER*2) error indicator (IER=0 is normal)
NOTE: For double precision use GAUSPD and don't forget to declare
A,B,X,D,C all to be REAL*8.
Note that A and B will be destroyed upon return.
Note that A is in row-order as indicated below